package org.rafal.springframework.controller;

import java.util.Locale;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rafal.springframework.helpers.Message;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/security")
public class SpringSecurityController {
	private static final Log LOG = LogFactory
			.getLog(SpringSecurityController.class);
	@Inject
	private MessageSource messageSource;

	@RequestMapping(value = "/loginfailed")
	public String loginfailed(Model model, Locale locale) {
		LOG.info("Log failed.");
		model.addAttribute(
				"message",
				new Message("Error", messageSource.getMessage("login_failed",
						new Object[] {}, locale)));
		return "login";
	}

}
